<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设备信息圈定')" />
    <style>

    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId" class="form-horizontal m">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>系统：</p>
                                <input  type="text" id="system" name="system" required="required"/>
                                <span><font color="red">*</font></span>
                                <span id="sys"></span>
                            </li>
                            <li>
                                <p>设备编码：</p>
                                <input  type="text" id="contentC" name="contentC" required="required" />
                                <span><font color="red">*</font></span>
                                <span id="cont"></span>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="checkRequired()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var drawCircle = [[${@permission.hasPermi('dxfcomponent:component:circle')}]];
        var editFlag = [[${@permission.hasPermi('dxfcomponent:component:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dxfcomponent:component:remove')}]];
        var prefix = ctx + "dxfcomponent/component";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                circleUrl : prefix + "/circle/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "dxf文件部件",
                pagination: false,
                columns: [
                {
                    title: "序号",
                    //width : '30%',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field : 'drawId',
                    title : '索引ID',
                    visible: false
                },
                {
                    field : 'fileCode',
                    title : '图纸编码'
                },
                {
                    field : 'fileName',
                    title : '图纸名称'
                },
                {
                    field : 'system',
                    title : '系统'
                },
                {
                    field : 'subitem',
                    title : '子项'
                },
                {
                    field : 'version',
                    title : '版本'
                },
                {
                    field : 'edition',
                    title : '版次'
                },

                {
                    field : 'componentId',
                    title : 'null',
                    visible: false
                },
                {
                    field : 'contentC',
                    title : '设备编码'
                },
                {
                    field : 'layer',
                    title : '图层'
                },
                {
                    field : 'positionX',
                    title : 'X坐标'
                },
                {
                    field : 'positionY',
                    title : 'Y坐标'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + drawCircle + '" href="javascript:void(0)" onclick="searchDraw(\'' + row.componentId + '\')"><i class="fa fa-edit"></i>圈定(供参考)</a>');
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.componentId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.componentId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function searchDraw(id) {
            var url = prefix + "/circle?componentId=" + id;

            if($.common.isEmpty(id) && table.options.type == table_type.bootstrapTreeTable) {
                var row = $("#" + table.options.id).bootstrapTreeTable('getSelections')[0];
                if ($.common.isEmpty(row)) {
                    $.modal.alertWarning("请至少选择一条记录");
                    return;
                }
                window.open(url);
            } else {
                window.open(url);
            }
        }

        /** 调用Java服务转化 */
        function twoCircle(id) {
            var url = prefix + "/twoCircle?componentId=" + id;

            window.open(url);
        }

        $("#formId").validate({
            focusCleanup: true
        });
        /***
         * 搜索验证是否必填
         */
        function checkRequired() {
            var system = $("#system").val();
            var content = $("#contentC").val();
            if(!system){
              // 请输入系统
                $("#sys").html("<font color='red'>必填</font>");
            }else{
                $("#sys").html('');
            }
            if(!content){
                // 请输入设备编码
                $("#cont").html("<font color='red'>必填</font>");
            }else{
                $("#cont").html('');
            }
            if(system && content){
                $.table.search();
            }
        }
        function reset(){
            $("#sys").html('');
            $("#cont").html('');
            $.form.reset()
        }
    </script>
</body>
</html>